//
//  AXFMyOrderViewController.m
//  AIXF
//
//  Created by zhanghui on 2017/7/14.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "AXFMyOrderViewController.h"
#import "AXFMyOrderViewModel.h"
#import "AXFMyOrderCell.h"
#import "AXFMyOrderDetailViewController.h"
#import <SVProgressHUD.h>

@interface AXFMyOrderViewController ()

@end

@implementation AXFMyOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupTableView];
    
    __weak typeof(self) weakSelf = self;
    

    [SVProgressHUD showWithStatus:@"正在加载..."];
    [_MyOrderVieModel requestOrderDataWithSussessBlock:^(NSArray<AXFMyOrderViewModel *> *viewModels) {
        [SVProgressHUD dismiss];
        [weakSelf.tableView reloadData];
    }];
}

#pragma mark - 初始化tableView
- (void)setupTableView{
    
    self.tableView.rowHeight = 200;
    
    //注册了cell
    [self.tableView registerNib:[UINib nibWithNibName:@"AXFMyOrderCell" bundle:nil] forCellReuseIdentifier:MyOrderCellID];
    
}

#pragma mark  - 数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    
    return _MyOrderVieModel.orderViewModel.count;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    AXFMyOrderCell *cell = [tableView dequeueReusableCellWithIdentifier:MyOrderCellID forIndexPath:indexPath];
    
   
    cell.orderModel = _MyOrderVieModel.orderViewModel[indexPath.row].orderModel;


    
    return cell;
}

#pragma mark - 点击cell
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    //跳转到具体的控制器
    AXFMyOrderDetailViewController *detail = [[AXFMyOrderDetailViewController alloc]init];
    
    [self.navigationController pushViewController:detail animated:YES];
    
    
}

//#pragma mark - 刷新数据
//- (void)didFinishLoadDataNotifitation{
//    
//    [self.tableView reloadData];
//}



@end
